﻿
@{
    ViewData["Title"] = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div id="divForm" style="margin:2px;padding:2px;">
    <el-form :model="form" label-width="120px">
        <el-row :gutter="24">
            <el-col :span="12">
                <el-form-item label="会员名称" required>
                    <el-input v-model="form.memberName" placeholder="会员名称"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="12">
                <el-form-item label="中文名称" required>
                    <el-input v-model="form.memberCnName" placeholder="中文名称"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="12">
                <el-form-item label="性别">
                    <el-radio-group v-model="form.sex">
                        <el-radio :label='1'>男</el-radio>
                        <el-radio :label='2'>女</el-radio>
                    </el-radio-group>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="12">
                <el-form-item label="会员等级" required> 
                    <el-select v-model="form.level" placeholder="请选择">
                        <el-option key="请选择" label="请选择" value="0"></el-option>
                        <el-option v-for="item in levelList"
                                   :key="item.id"
                                   :label="item.levelName"
                                   :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="12">
                <el-form-item label="手机号码" required>
                    <el-input v-model="form.mobile" placeholder="邮件"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="12">
                <el-form-item label="邮件" required>
                    <el-input v-model="form.email" placeholder="邮件"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="12">
                <el-form-item label="详细地址" required>
                    <el-input v-model="form.address" placeholder="详细地址"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="12">
                <el-form-item label="注册时间"> 
                    <el-date-picker v-model="form.registeTime"
                                    type="datetime"
                                    placeholder="选择注册时间">
                    </el-date-picker>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="12">
                <el-form-item label="头像">
                    <el-avatar shape="square" :size="100" :src="form.headPortrait" placeholder="头像"></el-avatar>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="12">
                <el-form-item label="状态">
                    <el-radio-group v-model="form.enabled">
                        <el-radio :label='true'>启用</el-radio>
                        <el-radio :label='false'>禁用</el-radio>
                    </el-radio-group>
                </el-form-item>
            </el-col>
        </el-row>
        <el-form-item>
            <el-button type="primary" @@click="SaveMember()" size="mini" v-show="pageButtons.includes('savemember')">保存</el-button>
            <el-button @@click="Back()" size="mini">返回</el-button>
        </el-form-item>
    </el-form>
</div>
<script>

    var vueNewsCategory = new Vue({
        el: '#divForm',
        data() {
            return {
                pageButtons: [],
                levelList:[],
                form: {
                    id: parseInt(getQueryString("id")||0),
                    memberName: "",
                    memberCnName: "",
                    sex:1,
                    level:'0',
                    mobile: '',
                    email: '',
                    address: '',
                    registeTime: '',
                    headPortrait: '',
                    enabled:true

                }
            }
        },
        created() {
            var _this = this;

            _this.GetMember();
            _this.GetMemberLevel();
            _this.$getMenuButtons();
        },
        methods: {
            GetMemberLevel() {
                  var _this = this;
                 _this.$get("@Url.Action("GetMemberLeveldList", "Member")" ).then((response) => {
                     _this.levelList = response;
                  }).catch((error) => {
                  });
            },
            GetMember() {
                var _this = this;
                _this.$get("@Url.Action("GetMember", "Member")?id="+_this.form.id ).then((res) => {
                    _this.form = res;
                });
            },
            SaveMember() {
                var _this = this;
                _this.form.orderIndex = parseInt(_this.form.orderIndex || 0);
                _this.$post("@Url.Action("SaveMember", "Member")", _this.form).then((res) => {
                    _this.$success(res.message, function () {
                        _this.$back(true);
                    });
                });
            },
            Back() {
                this.$back();
            }
        }
    });
</script>
